package top.xia17.plugins.fast.user.dao.repository;

import top.xia17.plugins.fast.common.database.jpa.extension.Xia17JpaRepository;
import org.springframework.data.jpa.repository.Query;
import top.xia17.plugins.fast.user.dao.entity.Role;

import java.util.List;

/**
 * @author xia17
 * @since 2021/7/29 11:36
 */
public interface RoleRepository extends Xia17JpaRepository<Role, Long> {

    /**
     * 查询
     *
     * @param name /
     * @return /
     */
    int countAllByName(String name);

    /**
     * 查询角色拥有的菜单ID
     *
     * @param id id
     * @return /
     */
    @Query(nativeQuery = true, value = "SELECT menu_id FROM sys_roles_menus WHERE role_id = ?1")
    List<Long> myFindRoleHasMenuIds(Integer id);
}
